package com.toubutu.audio.controller;

import com.toubutu.anno.LoginRequired;
import com.toubutu.audio.dto.DoCollectDto;
import com.toubutu.audio.dto.PageQueryCollectionDto;
import com.toubutu.audio.service.CollectionService;
import com.toubutu.audio.vo.CollectionVo;
import com.toubutu.common.PageUtils;
import com.toubutu.common.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 戒躁
 * @since 2024-02-26
 */
@RestController
@RequestMapping("/collection")
@Api(tags = "用户收藏接口管理")
@LoginRequired
public class CollectionController {
    @Resource
    private CollectionService collectionService;

    @PostMapping("/page")
    @ApiOperation("分页获取用户收藏")
    public Result<PageUtils<CollectionVo>> pageQuery(@RequestBody PageQueryCollectionDto dto){
        return Result.ok(collectionService.pageQueryCollection(dto));
    }

    @PostMapping("/do")
    @ApiOperation("收藏视频")
    public Result<Void> doCollect(@RequestBody DoCollectDto doCollectDto){
        collectionService.doCollect(doCollectDto);
        return Result.ok();
    }

}
